#pragma once

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

#include <errno.h>

#include <string>
#include <vector>
using namespace std;

namespace tnet
{
    class ServConf 
    {
    public:
        ServConf();
        virtual ~ServConf();
        
        int loadConf(const string& config);
        
        inline string   cfgGetIPAddr() { return m_ipaddr;};
        inline uint16_t cfgGetPort() { return m_port;};
        inline uint16_t cfgGetMaxprocess() { return m_maxProcess;};
        inline uint16_t cfgGetWorkerConnections() { return m_worker_connections;};
        inline uint16_t cfgGetMaxIdleTimeout() { return m_maxIdleTimeout; };
        inline uint16_t cfgGetLength() { return m_length; };
        inline bool     cfgIsReuseport() { return m_reuseport; };
        inline bool     cfgIsUnsock() {  return m_unsock; };
        inline string   cfgGetUnpath() { return m_unpath; };

    private:
        string m_config;
        string m_ipaddr;
        uint16_t m_port;
        uint16_t m_maxProcess;
        uint16_t m_worker_connections;
        uint16_t m_maxIdleTimeout;
        uint16_t m_length;
        uint16_t m_reuseport;
        uint16_t m_unsock;
        string   m_unpath;

        int readValue(vector<string>& rows);
    };
}
